package aeolus.wind.spider.biz.constants;

import org.apache.commons.lang.StringUtils;

import aeolus.wind.spider.biz.dataobject.Identity;

public class LoginItem {

    private Identity identity;
    private String   leaderGroupName;
    private String   myGroupName;
    private boolean  isRoot;

    public LoginItem() {
        identity = null;
    }

    public LoginItem(Identity identity) {
        this.identity = identity;
    }

    public void setLeaderGroupName(String leaderGroupName) {
        this.leaderGroupName = leaderGroupName;
    }

    public void setRoot(boolean isRoot) {
        this.isRoot = isRoot;
    }

    public boolean isLogin() {
        return identity == null ? false : true;
    }

    public Identity getLoginIdentity() {
        return identity;
    }

    public String getMyLoginName() {
        return identity.getName();
    }

    public String getMyGroupName() {
        if (myGroupName == null) {
            myGroupName = StringUtils.isBlank(identity.getGroupName()) ? identity.getName() + "的团队" : identity.getGroupName();
        }
        return myGroupName;
    }

    public String getMyLeaderName() {
        return identity.getLeaderName();
    }

    public String getMyLeaderGroupName() {
        if (leaderGroupName == null) {
            leaderGroupName = identity.getLeaderName() + "的团队";
        }
        return leaderGroupName;
    }

    public boolean isAbleToLeadGroup() {
        return identity.isAbleToLeadGroup();
    }

    public boolean isRoot() {
        return isRoot;
    }

}
